﻿using Abp.Application.Features;
using Abp.Application.Navigation;
using Abp.Localization;
using Partner.Surround.Authorization;
using Partner.Surround.Features;

namespace Partner.Surround.Web.Startup
{
    /// <summary>
    /// 菜单配置项
    /// </summary>
    public class SurroundNavigationProvider : NavigationProvider
    {
        public override void SetNavigation(INavigationProviderContext context)
        {
            context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        PageNames.Home,
                        L(PageNames.Home),
                        icon: "&#xe696;",
                        url: "/Home/Console",
                        requiredPermissionName: PermissionNames.Pages
                    )
                ).AddItem(
                    new MenuItemDefinition(//基础设施
                        PageNames.BaseManage,
                        L(PageNames.BaseManage),
                        icon: "&#xe6ae;",
                        requiredPermissionName: PermissionNames.Pages_Base
                    ).AddItem(
                        new MenuItemDefinition(
                            PageNames.DataDictionary,
                            L("DataDictionary"),
                            url: "/Base/DataDictionary",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Base_DataDictionary
                        )
                    )
                ).AddItem(
                    new MenuItemDefinition(//基础支撑
                        PageNames.FrameManage,
                        L(PageNames.FrameManage),
                        icon: "&#xe828;",
                        requiredPermissionName: PermissionNames.Pages_Frame
                    ).AddItem(
                        new MenuItemDefinition(//组织机构
                            PageNames.OrganizationUnits,
                            L(PageNames.OrganizationUnits),
                            url: "/OrganizationUnits",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Frame_OrganizationUnits
                        )
                    ).AddItem(
                        new MenuItemDefinition(//用户管理
                            PageNames.Users,
                            L(PageNames.Users),
                            url: "/Users",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Frame_Users
                        )
                    ).AddItem(
                        new MenuItemDefinition(//角色管理
                            PageNames.Roles,
                            L(PageNames.Roles),
                            url: "/Roles",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Frame_Roles
                        )
                    ).AddItem(
                        new MenuItemDefinition(//系统设置
                            PageNames.HostSettings,
                            L(PageNames.HostSettings),
                            url: "/HostSettings",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Frame_HostSettings
                        )
                    ).AddItem(
                        new MenuItemDefinition(//系统维护
                            PageNames.Maintenance,
                            L(PageNames.Maintenance),
                            url: "/Maintenance",
                            icon: "&#xe6cb;",
                            requiredPermissionName: PermissionNames.Pages_Frame_Maintenance
                        )
                    )
                );
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, SurroundConsts.LocalizationSourceName);
        }
    }
}
